class Solution {
public:
    //dp[i]表示：包含下标i元素的最长递增子序列的长度
    int lengthOfLIS(vector<int>& nums) {
        int ret = 1, n = nums.size();
        vector<int> dp(n, 1);

        for (int i = 1; i < n; i++)
        {
            int tmp = INT_MIN;
            for (int j = 0; j < i; j++)
            {
                if (nums[j] < nums[i])
                    tmp = max(tmp, dp[j]);
            }

            dp[i] = max(dp[i], dp[i] + tmp);
            ret = max(dp[i], ret);
        }

        return ret;
    }
};